import 'package:flutter/material.dart';
import 'package:flutter_custom_bottom_tab_bar/eachtab.dart';
import 'package:flutter_custom_bottom_tab_bar/flutter_custom_bottom_tab_bar.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:panda/base/Constant.dart';
import 'package:panda/set/TuiGuangMingXi.dart';
import 'package:panda/set/TuiGuangShouyi.dart';
import 'package:panda/set/YeJiChild.dart';

import 'MyJinShenShenhe.dart';

class YeJiPage extends StatefulWidget {
  YeJiPage({Key key}) : super(key: key);

  @override
  _YeJiPageState createState() => _YeJiPageState();
}

class _YeJiPageState extends State<YeJiPage>
    with SingleTickerProviderStateMixin {
  TabController _tabController;
  String badgeNo1;
  var titles = ['个人业绩', '团队业绩', '全民分红','团队分红'];

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _tabController =
        new TabController(vsync: this, initialIndex: 0, length: titles.length);
    badgeNo1 = '12';
  }

  @override
  void dispose() {
    _tabController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    final size = MediaQuery.of(context).size;
    ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context);
    final width = size.width;
    return new Scaffold(
      backgroundColor: white,
      appBar: PreferredSize(
        child: AppBar(
          brightness: Brightness.light,
          backgroundColor: white,
          elevation: 0,
        ),
        preferredSize: Size.fromHeight(0),
      ),
      body: Column(children: <Widget>[
        Row(children: <Widget>[
          Expanded(
              child: GestureDetector(
                  child: Container(
                    color: white,
                    child: Icon(
                      Icons.arrow_back_ios,
                    ),
                    padding: EdgeInsets.all(10),
                  ),
                  onTap: () {
                    Navigator.of(context).pop();
                  })),
          TabContainer(
              // alignment: Alignment.center,
              color: Colors.white,
              child: Stack(
                overflow: Overflow.clip,
                children: <Widget>[
                  Container(
                    child: new TabBar(
                      isScrollable: true,
                      controller: _tabController,
                      indicatorColor: mainColor,
                      labelColor: mainColor,
                      labelPadding: EdgeInsets.all(0),
                      unselectedLabelColor: Colors.black,
                      tabs: <Widget>[
                        EachTab(
                          text: titles[0],
                          textStyle: TextStyle(
                              fontSize: ScreenUtil.getInstance()
                                  .setSp(NORMAL_FONT_SIZE-2)),
                        ),
                        EachTab(
                          text: titles[1],
                          textStyle: TextStyle(
                              fontSize: ScreenUtil.getInstance()
                                  .setSp(NORMAL_FONT_SIZE-2)),
                        ),
                        EachTab(
                          text: titles[2],
                          textStyle: TextStyle(
                              fontSize: ScreenUtil.getInstance()
                                  .setSp(NORMAL_FONT_SIZE-2)),
                        ),EachTab(
                          text: titles[3],
                          textStyle: TextStyle(
                              fontSize: ScreenUtil.getInstance()
                                  .setSp(NORMAL_FONT_SIZE-2)),
                        ),
                        // new EachTab(
                        //   width: width / 4,
                        //   padding: EdgeInsets.fromLTRB(
                        //       ScreenUtil.getInstance().setWidth(DP_50),
                        //       0,
                        //       10,
                        //       0),
                        //   text: titles[3],
                        //   textStyle: TextStyle(
                        //       fontSize: ScreenUtil.getInstance()
                        //           .setSp(NORMAL_FONT_SIZE)),
                        // ),
                        // new EachTab(
                        //   width: width / 5,
                        //   text: titles[4],
                        //   textStyle: TextStyle(
                        //       fontSize: ScreenUtil.getInstance().setSp(NORMAL_FONT_SIZE)),
                        // ),
                      ],
                    ),
                  ),
                ],
              )),
          Expanded(
              child: Container(
            color: white,
            width: 100,
          )),
        ]),
        Expanded(
            child: TabBarView(controller: _tabController, children: <Widget>[
          Container(
            color: Colors.grey[100],
              child: new YeJiChildPage(
            type: 1,
          )),
          Container(
            color: Colors.grey[100],
              child: YeJiChildPage(
            type: 2,
          )),
           Container(
            color: Colors.grey[100],
              child: YeJiChildPage(
            type: 3,
          )),
           Container(
            color: Colors.grey[100],
              child: TuiGuangShouYiPage()),
          // Center(child: AllOrderPage(type: 9,)),
        ]))
      ]),
    );
  }
}
